package com.chenc.javathreads.controlleraop.controller;

import com.chenc.javathreads.controlleraop.aspect.ControllerLog;
import com.chenc.javathreads.controlleraop.dto.UsualParam;
import com.chenc.javathreads.controlleraop.service.UsualService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.util.Arrays;
import java.util.List;

/**
 * @ClassName
 * @Describtion:
 * @Author:Chenc
 * @Date:2023/12/16 20:53
 * @Version 1.0
 */

@Slf4j
@RestController
@RequestMapping("/usual")
public class UsualController {

    @Autowired
    UsualService usualService;

    @GetMapping("/query/{orderNo}")
    @ControllerLog
    public String queryOrderNo(@PathVariable("orderNo")String orderNo){
        log.info("orderNo:{}",orderNo);
        return orderNo;
    }

    @GetMapping("/queryparam")
    public List<UsualParam> queryOrderParams(@RequestParam String param){

        if (param.equals("111")){
            throw new RuntimeException("12321");
        }
        return Arrays.asList(UsualParam.builder().param1("1").param2("2").param3("5").build());
    }

    @PostMapping("/insert")
    @ControllerLog
    public List<UsualParam> insertDtos(@RequestBody List<UsualParam> param){
        log.info("param:{}",param);
        return param;
    }


}
